import { Member } from './member'
import { ShopWork } from './shop/shop-work.entity'
import { OneToMany, Entity, Column, PrimaryGeneratedColumn, ManyToOne } from 'typeorm'

@Entity()
export class Car {
  @PrimaryGeneratedColumn()
  id: number

  @Column({
    comment: '车牌号',
    unique: true
  })
  carnumber: string

  @Column({
    comment: '车架号',
    unique: true
  })
  jarnumber: string

  @Column({
    comment: '行驶里程'
  })
  licheng: string

  /**
   * 会员
   * 一个汽车有一个会员，一个会员有多个汽车
   */
  @ManyToOne(type => Member, member => member.cars)
  member: Member

  @OneToMany(type => ShopWork, work => work.car)
  works: ShopWork[]
}
